package com.l024.user.service.impl;

import com.l024.common.utils.StringUtils;
import com.l024.model.user.MeetUser;
import com.l024.user.mapper.MeetUserMapper;
import com.l024.user.service.MeetUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MeetUserServiceImpl implements MeetUserService {

    @Autowired
    private MeetUserMapper meetUserMapper;

    @Override
    public MeetUser getUser(MeetUser meetUser) {
        if(!userIsNull(meetUser)){
            return meetUserMapper.getUser(meetUser);
        }
        return null;
    }

    /**
     * 获取用户信息以及角色权限信息
     */
    @Override
    public MeetUser getUserAndRoleAndPermissions(MeetUser meetUser) {
        if(!userIsNull(meetUser)){
            return meetUserMapper.getUserRoleAndPermissions(meetUser);
        }
        return null;
    }

    /**
     * 判断用户是否为null
     */
    private boolean userIsNull(MeetUser meetUser){
        if(meetUser!=null){
            if(StringUtils.isEmptyNumber(meetUser.getUId())
                    &&StringUtils.isEmpty(meetUser.getUName())
                    &&StringUtils.isEmpty(meetUser.getUPhone())
                    &&StringUtils.isEmpty(meetUser.getUEmail())){
                return true;
            }else{
                return false;
            }
        }
        return true;
    }

}
